home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / util / pack / xpk_Source.lha / xpk_Source / test / testFullPack.c < prev    next >
C/C++ Source or Header  |  1998-02-08  |  3KB  |  111 lines

  1. #define NAME        "testFullPack"
  2. #define DISTRIBUTION    "(Freeware) "
  3. #define REVISION    "2"
  4.  
  5. /* Programmheader
  6.  
  7.     Name:        testFullPack
  8.     Author:        SDI
  9.     Distribution:    Freeware
  10.     Description:    tests all packmodes with all file-sizes to 100000
  11.     Compileropts:    -
  12.     Linkeropts:    -l xpkmaster amiga
  13.  
  14.  1.0   15.05.97 : first version to find IDEA error
  15.  1.1   16.05.97 : changed output format (shorter)
  16.  1.2   17.05.97 : fixed a wrong parameter
  17. */
  18.  
  19. #include <proto/exec.h>
  20. #include <proto/dos.h>
  21. #include <proto/xpkmaster.h>
  22. #include <exec/memory.h>
  23. #include "SDI_defines.h"
  24.  
  25. struct Library        *XpkBase        = 0;
  26. ULONG            DosVersion        = 37;
  27.  
  28. #define PARAM "METHOD,START/N,PASSWORD,FILE,STEP/N"
  29.  
  30. void main(void)
  31. {
  32.   ULONG noth = 1, step = 1;
  33.   struct RDArgs    *rda;
  34.   struct args
  35.   {
  36.     STRPTR method;
  37.     ULONG *start;
  38.     STRPTR password;
  39.     STRPTR file;
  40.     ULONG *step;
  41.   } args = {"IDEA", 0, "TestPwd", "testFullPack.out", 0};
  42.  
  43.   args.start = ¬h;
  44.   args.step = &step;
  45.  
  46.   if((rda = ReadArgs(PARAM, (LONG *) &args, 0)))
  47.   {
  48.     if((XpkBase = OpenLibrary(XPKNAME, 0)))
  49.     {
  50.       STRPTR ibuf;
  51.  
  52.       if((ibuf = (STRPTR) AllocMem(100000, MEMF_CLEAR)))
  53.       {
  54.         STRPTR obuf;
  55.  
  56.         if((obuf = (STRPTR) AllocMem(200000, MEMF_ANY)))
  57.         {
  58.           ULONG fh;
  59.  
  60.       if((fh = Open(args.file, MODE_READWRITE)))
  61.           {
  62.             ULONG i, j, olen;
  63.             LONG err;
  64.  
  65.         Seek(fh, 0, OFFSET_END);
  66.  
  67.         for(i = 0; i < 100000; ++i)
  68.           ibuf[i] = i;
  69.  
  70.             for(i = *args.start; !CTRL_C && i <= 100000; i += *args.step)
  71.             {
  72.               Printf("%6ld: ", i);
  73.               FPrintf(fh, "%6ld: ", i);
  74.               for(j = 0; !CTRL_C && j <= 100; ++j)
  75.               {
  76.                 if((err = XpkPackTags(XPK_InBuf, ibuf, XPK_InLen, i,
  77.                   XPK_PackMethod, args.method, XPK_OutBuf, obuf,
  78.                   XPK_OutBufLen, 200000, XPK_GetOutLen, &olen, XPK_Password,
  79.                   args.password, XPK_PackMode, j, TAG_DONE)))
  80.                   {
  81.                     Printf("p%03ld(%02ld), ", j, -err);
  82.                     FPrintf(fh,"p%03ld(%02ld), ", j, -err);
  83.                   }
  84.                 else if((err = XpkUnpackTags(XPK_InBuf, obuf, XPK_InLen, olen,
  85.                   XPK_OutName, "NIL:", XPK_Password, args.password, TAG_DONE)))
  86.                   {
  87.                     Printf("u%03ld(%02ld), ", j, -err);
  88.                     FPrintf(fh,"u%03ld(%02ld), ", j, -err);
  89.                   }
  90.               }
  91.               if(CTRL_C)
  92.               {
  93.                 Printf("\nbreak:  %03ld", j);
  94.                 FPrintf(fh, "\nbreak:  %03ld", j);
  95.               }
  96.               Printf("\n");
  97.               FPrintf(fh, "\n");
  98.             }
  99.             Close(fh);
  100.           }
  101.           FreeMem(obuf, 200000);
  102.         }
  103.         FreeMem(ibuf, 100000);
  104.       }
  105.       CloseLibrary(XpkBase);
  106.     }
  107.     FreeArgs(rda);
  108.   }
  109. }
  110.  
  111.